package com.specter.sure.core;

/**
 * Note:认证常量
 * 
 * @author Liang.Wang
 * @version Apr 20, 2011 12:42:16 AM
 */
public class AuthConsts {

	public enum Level {

		NONE(0), // 不过滤任何权限
		LOW(1), // 只过滤session
		MIDDLE(2), // 只过滤登记过的权限 和 session
		HIGH(3); // 只允许被排除的访问

		private int value;

		private Level() {
		}

		private Level(int value) {
			this.value = value;
		}

		public int getValue() {
			return value;
		}
	}

	/**
	 * 密码加密器
	 * 
	 * @author Liang.Wang
	 * @version V1.0
	 * @note
	 */
	public enum Encoder {

		MD5("md5"), // 只对密码进行MD5加密
		MD5_SALT("md5_salt"), // 将用户名和密码连接在一起以后再用MD5加密
		TXT("txt");// 使用明文，没有进行加密

		private String value;

		Encoder(String value) {
			this.value = value;
		}

		@Override
		public String toString() {
			return value;
		}
	}

	// -----------登录参数-------------//
	/** 用户名参数名 */
	public static final String PARAMS_LOGIN_ID = "specter_security_params_loginid";
	/** 密码参数名 */
	public static final String PARAMS_PASSWORD = "specter_security_params_password";
	/** 验证码参数名 */
	public static final String PARAMS_CAPTCHA = "specter_security_params_captcha";
	/** 记住用户参数名 */
	public static final String PARAMS_COOKIE = "specter_security_params_cookie";

	// -----------内置地址-------------//
	/** 登录认证处理 */
	public static final String URL_NAUTH_AUTHORIZE = "/sure/nauth/authorize";
	/** 登出注销处理 */
	public static final String URL_NAUTH_INVALIDATE = "/sure/nauth/invalidate";
	/** 验证错误处理 */
	public static final String URL_NAUTH_FAILURE = "/sure/nauth/failure";
	/** 单点认证处理 */
	public static final String URL_SAUTH_AUTHORIZE = "/sure/sauth/authorize";
	/** 单点回调处理 */
	public static final String URL_SAUTH_CALLBACK = "/sure/sauth/callback";
	/** 单点获取信息 */
	public static final String URL_SAUTH_GIVE2ME = "/sure/sauth/me";
	/** 认证获取令牌 */
	public static final String URL_OAUTH_TOKEN = "/sure/oauth/access_token";
	/** 检查校验令牌 */
	public static final String URL_OAUTH_VALID = "/sure/oauth/valid_token";
	/** 认证获取令牌 */
	public static final String URL_OAUTH_ACCESS = "/sure/oauth/access";
	/** 检查校验令牌 */
	public static final String URL_OAUTH_AUTHORIZE = "/sure/oauth/authorize";

	// -----------常量标记-------------//
	/** SERVLET_CONTEXT 中存放的permissions的key */
	public static final String KEY_CONTEXT_PERMISSIONS = "specter_key_context_permissions";
	/** SESSION中存放的from的key */
	public static final String KEY_SESSION_FROM = "specter_key_session_from";

	// -----------令牌标记-------------//
	/** token从session中获取 */
	public static final String TOKEN_FROM_SESSION = "specter_session_token";
	/** token从cookie中获取 */
	public static final String TOKEN_FROM_COOKIE = "specter_cookie_token";
	/** token从cache中获取 */
	public static final String TOKEN_FROM_CACHE = "specter_cache_token";
	/** token从request中获取 */
	public static final String TOKEN_FROM_OAUTH2 = "access_token";
	/** token从header中获取 */
	public static final String TOKEN_FROM_HEADER = "Authorization";

	// -----------错误常量-------------//
	/** 验证码错误 */
	public static final String ERROR_CAPTCHA_ERROR = "specter_captcha_error";
	/** 密码错误 */
	public static final String ERROR_PASSWORD_ERROR = "specter_password_error";
	/** 用户不存在错误 */
	public static final String ERROR_NOUSER_ERROR = "specter_nouser_error";
	/** 不允许访问错误 */
	public static final String ERROR_DISALLOW_ERROR = "specter_disallow_error";
	/** 认证错误 */
	public static final String ERROR_AUTHORIZE_EXCEPTION = "specter_authorize_exception";
	/** 授权错误 */
	public static final String ERROR_PRIVILEGE_EXCEPTION = "specter_privilege_exception";

}
